#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "TestSalesData.cpp"
using namespace std;
istream& read(istream&);
void practice_8_1();
void practice_8_4();
void practice_8_5();
void practice_8_6(int argc,char **argv);
void practice_8_10();
int main(int argc,char **argv)
{
	//practice_8_1();
	//practice_8_4();
	//practice_8_5();
	//practice_8_6(argc,argv);
	practice_8_10();
	return 0;
}
istream& read(istream &is)
{
	string line,word;
	while(!is.eof()){
		getline(is,line);
		istringstream iss(line);
		while(iss>>word)
			cout<<word<<endl;
	}
	is.clear();
	return is;
}
void practice_8_1()
{
	read(cin);
}
void practice_8_4()
{
	string word;
	vector<string> v;
	ifstream in("inputLine.txt");
	while(getline(in,word)){
		v.push_back(word);
	}
	in.close();
	for(auto &s:v)
		cout<<s<<endl;
}
void practice_8_5()
{
	string word;
	vector<string> v;
	ifstream in("inputWord.txt");
	while(in>>word){
		v.push_back(word);
	}
	in.close();
	for(auto &s:v)
		cout<<s<<" ";
}
void practice_8_6(int argc,char **argv)
{
	ifstream input("Sales_Item.txt");
	ofstream output;
	output.open("Sales_Item_Output.txt",ofstream::app);
	Sales_data total(input);
	if(!total.isbn().empty()){
		istream &is=input;
		while(is){
			Sales_data trans(is);
			if(total.isbn() == trans.isbn()){
				total.combine(trans);
			}
			else{
				print(output,total)<<endl;
				total=trans;
			}
		}
		//print(output,total)<<endl;
	}
	else{
		throw std::runtime_error("input illegal");
	}
	input.close();
	output.close();
}
void practice_8_10()
{
	string line,word;
	vector<string> v;
	ifstream input("Sales_Item.txt");
	while(getline(input,line))
		v.push_back(line);
	for(const string &s:v){
		istringstream iss(s);
		while(iss>>word)
			cout<<word<<endl;
	}
}